/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gephi.statistics.spi.path;

import java.util.HashMap;

/**
 *
 * @author lczgywzyy
 */
public class LSparse_Matrix {

    public static final LSparse_Matrix getInstance() {
        return instance;
    }

    private static final LSparse_Matrix instance = new LSparse_Matrix();

    public HashMap<Integer, HashMap<Integer, Integer>> getMatrix() {
        return matrix;
    }

    private final static HashMap<Integer, HashMap<Integer, Integer>> matrix = new HashMap<Integer, HashMap<Integer, Integer>>();

//    LSparse_Matrix(int x, int y) {
//        HashMap<Integer, Float> tmp = new HashMap<Integer, Float>();
//        tmp.put(y, 0.0f);
//        matrix.put(x, tmp);
//    }
//
//    LSparse_Matrix(int x, int y, float value) {
//        LSparse_Matrix(x, y);
//        matrix.get(x).put(y, value);
//    }
    public void setValue(int x, int y, int value) {
        if (matrix.get(x) == null) {
            HashMap<Integer, Integer> tmp = new HashMap<Integer, Integer>();
            matrix.put(x, tmp);
        }
        matrix.get(x).put(y, value);
    }

    public int getValue(int x, int y) {
        return (matrix.get(x) == null || matrix.get(x).get(y) == null) ? 0: matrix.get(x).get(y);
    }

}
